package com.yociyy.sms.validate.code.sms;

import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.ServletWebRequest;

import com.yociyy.sms.properties.SmsProperties;
import com.yociyy.sms.validate.code.ValidateCode;
import com.yociyy.sms.validate.code.ValidateCodeGenerator;

import java.util.Map;

/**
 * 短信验证码生成器
 *
 * @author: YoCiyy
 * @date: 2020/5/26
 */
public class SmsCodeGenerator implements ValidateCodeGenerator {

	@Autowired
	private SmsProperties securityProperties;

	public ValidateCode generate(ServletWebRequest request) {
		String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength());
		return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn());
	}

	@Override
	public ValidateCode generate(Map<String, Object> params) {
		return null;
	}
}
